/*
*   Queue.h
*   Authors: Dustin Striplin, Bill Minter, Wilson Burhan
*   Holds objects of type PCBPtr, implemented as a singley linked list.
*/

#include "global.h"
#include "pcb.h"

#ifndef QUEUE_H
#define QUEUE_H


typedef struct node {
    PCBPtr contents;
    struct node* next;
} NodeStr;

typedef NodeStr* NodePtr;

NodePtr nodeConstructor(PCBPtr conents);


typedef struct queue {
    NodePtr head;
    NodePtr tail;

    void(*destruct)(struct queue*);
    void(*destructAll)(struct queue*);
    bool(*isEmpty)(struct queue*);
    int(*enqueue)(struct queue*, PCBPtr);
    PCBPtr(*dequeue)(struct queue*);
    PCBPtr(*peek)(struct queue*);
} QueueStr;

typedef QueueStr* QueuePtr;

QueuePtr queueConstructor();
void queueDestructor(QueuePtr this);
void queueDestructAll(QueuePtr this);   //destroys all processes, pcbs, nodes, and the queue.

int queueEnqueue(QueuePtr this, PCBPtr pcb);  //add the pcb to the queue
bool queueIsEmpty(QueuePtr this);   //is it empty?
PCBPtr queueDequeue(QueuePtr this);   //remove the last node & return the pcbstr that it contains
PCBPtr queuePeek(QueuePtr this);      //peek

#endif
